package com.gitee.huxing.course.conc.conc01;

/**
 * @Description: 线程池理解demo
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.conc
 * @ClassName: DemoThread
 * @Author: huxing
 * @DateTime: 2021-08-20 上午9:16
 */
public class DemoThread {

    public static void main(String[] args) throws Exception{
        Runnable task = () -> {
            try {
                Thread.sleep(5000L);
            } catch (Exception ex){
                ex.printStackTrace();
            }
            Thread t = Thread.currentThread();
            System.out.print("当前线程的名称: "+ t.getName());
        };
        // 创建一个新的线程
        Thread thread = new Thread(task);
        thread.setName("test-thread-1");
        thread.setDaemon(true);
        thread.start();
        Thread.sleep(5000L);
    }
}
